<?php
      class gongnengAction{
    //发送短信
    public function sendmsgsave()
    {
        if (I('post.phone') <> '') {
            $tel = I('post.phone');
            //var_dump($tel);
        }
        if (!I('post.content')) {
            echo '内容不能为空';
            return;
        }
        $msg = I('post.content');
        $phone = floatval($tel);//电话号码
        if (strlen($phone) == 11) {

            $url = "http://smsapi.c123.cn/OpenPlatform/OpenApi?action=sendOnce&ac=1001@500959270001&authkey=6C10F43C6901A5D0EEEBA5196EA48E90&cgid=1650&csid=6183&c=" . urlencode($msg) . "&m=" . $phone;
            if (1) {
                $ch = curl_init();
                $timeout = 5;
                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
                $J = curl_exec($ch);
            }
            $str.="发送成功;";
        }else{
            $str.= $phone."请输入正确的手机号码;";

        }

        echo $str;
    }


          //上传文件  举例
          //前台代码 html代码------------------------------------------------------------------------------------------------------------
          /*
           <tr>
           <td>上传身份证正面照片:</td>
           <td><input id="sffiles"  name="sffiles" type="file" multiple><input type="hidden" id="shenfenzhengzhaopian" name="sffile" /></td>
           </tr>
            */
          //前台代码 JS代码------------------------------------------------------------------------------------------------------------
          //需要获取表单的id"shenfenzhengzhaopian"
          /*
           例如:
          <a id="btn"  class="easyui-linkbutton"  onClick="$.messager.progress();

                                                      $.ajax({
                                                        url: '__URL__/baoming_okes/id/<{$id}>/keyes/1',
                                                        type:'POST',
                                                         data:{'sffile':$('#shenfenzhengzhaopian').val()}, //获取表单的id
                                                        success:function(data){
                                                                $.messager.alert('提示信息',data,'info')
                                                                $.messager.progress('close');
                                                                $.modalDialog2.handler.dialog('close');
                                                                $('#baoming1<{$ides}>').datagrid('reload');
                                                        }
                                                        })
                                                          " data-options="iconCls:'icon-save'">保存</a>
           */
          //前台代码 JS方法------------------------------------------------------------------------------------------------------------
          /*
          $(function() {
        $('#sffiles').uploadify({
            'swf'      : '__PUBLIC__/js/uploadify.swf',    //指定上传控件的主体文件
            'uploader' : '/admin.php/Public/upload',//指定服务器端上传处理文件（后台处理方法路径）
            'fileSizeLimit' : '500KB',
            'buttonText':'上传身份证正面照片',//按钮名称
            'height':'25px',
            'fileDesc':'jpg/gif/jpeg/png/bmp/doc/rar/zip/xls/docx/pdm/pdb/pdf/ppt',
            'multi':'false',
            'progressData':'speed',
            'uploadLimit' : 1,
            'onUploadProgress' : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
                $('#progress2<{$ides}>').html('已上传'+totalBytesUploaded + ' 字节。共 ' + totalBytesTotal + ' 字节.');
            }  ,
            'onFallback' : function() {
                alert('未检测到兼容版本的Flash.');
            },
            'onUploadSuccess' : function(file, data, response) {
                eval('data = '+data+';');
                if(data.errno){
                    $.messager.alert('提示信息','竞投文件上传失败'+data.errdesc,'info');
                }else{
                    $.messager.alert('提示信息','竞投文件上传成功','info');
                    $('#shenfenzhengzhaopian').val(data.filename);//获取input的id
                }
            },
            'onUploadError' : function(file, errorCode, errorMsg, errorString) {
                alert(file.name + ' 上传失败。详细信息: ' + errorString);
            }
            //其他配置项
          });
          });------------------------------------------------------------------------------------------------------------
           */
          //后台方法
          public function upload()
          {
              $return = array('errno'=>0,'errdesc'=>'','filename'=>'');
              $targetFolder = '/Public/uploads';//保存路径

              $verifyToken = md5('unique_salt' .$_FILES['Filedata']);
              if (!empty($_FILES) == $verifyToken) {
                  $tempFile = $_FILES['Filedata']['tmp_name'];
                  $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
                  $fileParts = pathinfo($_FILES['Filedata']['name']);
                  $filename = rand(100000,9999999).strtotime(date('Y-m-d H:i:s')).".".$fileParts['extension'];
                  $targetFile = rtrim($targetPath,'/') . '/' .$filename;
                  $fileTypes = array('jpg','jpeg','gif','png','doc','docx','pdf','xls','xlsx'); // File extensions 文件格式


                  if (in_array($fileParts['extension'],$fileTypes)) {
                      move_uploaded_file($tempFile,$targetFile);
                      $return['filename'] =  $filename;
                  } else {
                      $return['errno'] = 1;
                      $return['errdesc'] =  'Invalid file type.';
                  }
              }

              $this->ajaxReturn($return);

          }














}
?>